<template>
  <div class="store-info">
    
    <div class="store-logo">
      <img :src="storeInfo.logo" alt="">
      <span>{{storeInfo.name}}</span>
    </div>

    <div class="store-msg">
      <div class="store-sell">
        <div class="sells">
          <span class="sells-data">{{sells}}</span>
          <span class="sells-data">{{storeInfo.goods}}</span>
        </div>
        <div class="sells">
          <span class="sells-data data--font">总销量</span>
          <span class="sells-data data--font">全部宝贝</span>
        </div>
      </div>
      <div class="border"></div>
      <div class="store-score">
        <div class="store-describe" v-for="(item, index) in storeInfo.score" :key="index">
          <span class="describe-name">{{item.name}}</span>
          <span class="describe-score"
          :class="{bettercolor: !item.isBetter}">{{item.score}}</span>
          <span class="describe-better" 
          :class="{bgcolor: !item.isBetter}">{{isBetter(item.isBetter)}}</span>
        </div>
      </div>
    </div>
    <div class="in-store">
      <div class="store-btn">进店逛逛</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DetailStoreInfo',
  props: {
    storeInfo: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  computed: {
    sells() {// 将销售的总数处理
      if (this.storeInfo.Sells){
      
        const length = this.storeInfo.Sells.toString().length;
        let number = this.storeInfo.Sells.toString();
        
        if(length >= 5) {
          const w = number.substr(0, length - 4);
          const q = number.substr(length - 4, length - 4);
          const sell = w + '.' + q + '万';
          return sell;
        }
      }
      
      
    }
  },
  methods: {
    isBetter(isBetter) {// 店铺评分
      if(isBetter) {
        return '高'
      } else {
        return '低'
      }
    }
  }
}
</script>

<style scoped>
  .store-info{
    border-bottom: 9px solid rgba(112, 109, 109, 0.1);
  }
  /* 店铺logo区域 */
  .store-logo{
    font-size: 20px;
    padding: 30px 15px 40px;
  } 
  .store-logo img{
    width: 70px;
    border-radius: 200px;
    border: 1px solid rgba(189, 189, 189, .8)
  }
  .store-logo span{
    margin-left: 20px;
    vertical-align: 100%;
    
  }
  /* 店铺信息 */
  .store-msg{
    display: flex;
    text-align: center;
  }
  .store-sell{
    flex: 1;
    padding-top: 5px;

    display: flex;
    justify-content: space-around;
    flex-flow: column;
  }
  .store-sell .sells{
    flex: 1;
    
    display: flex;
    justify-content: space-around;
  }
  .store-sell .sells .sells-data{
    font-size: 25px;
  }
  .store-sell .sells .sells-data:nth-of-type(1){
    padding-left: 10px;
  }
  .store-sell .sells .sells-data:nth-of-type(2){
    padding-right: 10px;
  }
  .store-sell .sells .data--font{
    font-size: 16px!important;
    color: black;
    margin-left: 10px;
  }



  /* 店铺评分 */
  .store-score{
    flex: 1;
    color: black;
    padding-top: 5px;

    
  }
  .store-score .store-describe{

    line-height: 30px;
    display: flex;
    
  }
  .store-score .store-describe .describe-name{
    flex: 1;
  }
  .store-score .store-describe .describe-score{
    width: 50px;

    color: rgba(241,62,58, .8);
  }
  .store-score .store-describe .describe-better{
    width: 20px;
    line-height: 20px;
    height: 20px;
    margin-right: 30px;
    margin-top: 5px;
    color: white;
    background-color: rgba(241,62,58, .8);
  }
  .store-score .store-describe .bgcolor{
    background-color: rgb(69, 190, 144);
  }
  .store-score .store-describe .bettercolor{
    color: rgb(69, 190, 144);
  }
  /* 店铺信息中轴线 */
  .border{
    width: 1px;
    height: 60px;
    margin: 15px 0;
    background-color: rgba(112, 109, 109, 0.5)
  }

  /* 进店逛逛 */
  .in-store{
    margin-top: 15px;
    width: 100%;
    height: 70px;
  }
  .in-store .store-btn{
    margin: 0 auto;
    height: 40px;
    line-height: 40px;
    width: 60%;
    border-radius: 200px;
    text-align: center;
    background-color: rgba(189, 189, 189, .8);
  }
</style>